package jp.ac.waseda.cs.washi.game.entity;

import java.awt.Image;

import jp.ac.waseda.cs.washi.gameaiarena.gui.Renderer;

public class Tile {
	// ----- ----- ----- ----- fields ----- ----- ----- -----
	private Wall _wall;
	private Chara _incompleteOwner;
	private Chara _owner;
	private Image _backgroundImage;
	private int _strength;
	private boolean _canDevelop;

	// ----- ----- ----- ----- methods ----- ----- ----- -----
	public Tile(Image backgroundImage) {
		_backgroundImage = backgroundImage;
		_strength = 0;
		_canDevelop = true;
	}

	public boolean canDevelop() {
		return _canDevelop;
	}

	public void setCanDevelop(boolean lock) {
		_canDevelop = lock;
	}

	// ----- ----- ----- WALL ----- ----- -----
	public Wall getWall() {
		return _wall;
	}

	public boolean hasWall() {
		return _wall != null;
	}

	public void setWall(Wall wall) {
		_wall = wall;
	}

	public Chara getOwner() {
		return _incompleteOwner;
	}

	public void setIncompleteOwner(Chara incompleteOwner) {
		_incompleteOwner = incompleteOwner;
	}

	public Chara getCompleteOwner() {
		return _owner;
	}

	public void setOwner(Chara chara) {
		_owner = chara;
	}

	public int getStrength() {
		return _strength;
	}

	public void setStrength(int strength) {
		_strength = strength;
	}

	public void clear(Chara chara) {
		_strength = 0;
		_owner = _incompleteOwner = null;
	}
	
	public void draw(Renderer render, int x, int y) {
		render.drawImage(_backgroundImage, x * Map.BLOCK_WIDTH, y
				* Map.BLOCK_HEIGHT);
		if (_wall != null) {
			_wall.draw(render, x, y);
		} else if (_incompleteOwner != null) {
			// level に応じた数字を表示する
			render.drawImage(_incompleteOwner.getTerritoryImages()[_strength], x * Map.BLOCK_WIDTH, y * Map.BLOCK_HEIGHT);
		}

	}
}
